﻿<%@ Page Title="Requisition Approval" Language="C#" MasterPageFile="~/MasterPage.Master" AutoEventWireup="true"
    CodeBehind="Requisitions.aspx.cs" Inherits="KorleBu.Requisitions1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        .style1
        {
            width: 368px;
        }
        .style2
        {
            width: 322px;
        }
        .style3
        {
            width: 242px;
        }
        .style4
        {
            width: 118px;
        }
        .style5
        {
            width: 213px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="sidebarcontentplaceholder" runat="server">
    <p>
        <br />
        <asp:Label ID="lblLoggedInUser" runat="server" Font-Bold="true" Visible="true"/>
    </p>
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="maincontentplaceholder" runat="server">
    <asp:ScriptManager ID="ScriptManager" runat="server" />
    <br />
    <asp:UpdatePanel ID="UpdatePanel" runat="server">
        <ContentTemplate>
            <div id="ebar">
                <asp:Label runat="server" ID="lblMasterError" CssClass="errorLabel" />
            </div>
            <asp:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="0" 
                Width="100%">
                <asp:TabPanel ID="ViewRequisitions" runat="server" HeaderText="Approve/Deny Requisition">

                    <ContentTemplate>
                        <fieldset style="width: 573px; min-height: 176px;">
                            <legend>View Requisitions</legend>
                            <asp:Label ID="lblError" runat="server"></asp:Label>
                            <br />
                            <asp:MultiView ID="mvRequisition" runat="server" ActiveViewIndex="0">
                                <asp:View ID="vSelectRequisition" runat="server">
                                    <asp:GridView ID="gvRequisition" runat="server" AutoGenerateColumns="False" 
                                        onrowcommand="gvRequisition_RowCommand">
                                        <RowStyle HorizontalAlign="Right" VerticalAlign="Middle" />
                                        <Columns>
                                            <asp:BoundField DataField="RequisitionID" HeaderText="Requisition ID" />
                                            <asp:BoundField DataField="RequisitionName" HeaderText="Requisition Description" />
                                            <asp:BoundField DataField="orderDate" HeaderText="Order Date" />
                                            <asp:BoundField DataField="StoreName" HeaderText="Store Name" />
                                            <asp:TemplateField HeaderText="Status">
                                                <ItemTemplate>
                                                    <asp:Label runat="server" ID="lblStatusName" Text='<%# Bind("StatusName") %>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:CommandField ButtonType="Button" ShowSelectButton="True" />
                                        </Columns>
                                    </asp:GridView>
                                </asp:View>
                                <asp:View ID="vViewRequisitionItems" runat="server">
                                    <table ID="CreateRequest" style="width:100%;">
                                        <tr>
                                            <td style="width:50%;">
                                                <strong>Requisition ID: </strong>
                                                <asp:Label ID="lblRequisitionID" runat="server"></asp:Label>
                                            </td>
                                            <td>
                                                <strong>Submit Date: </strong>
                                                <asp:Label ID="lblRequisitionDate" runat="server"></asp:Label>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td colspan="2">
                                                <strong>Description: </strong>
                                                <asp:Label ID="lblDescription" runat="server"></asp:Label>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td colspan="2">
                                                <strong>Requesting Store: </strong>
                                                <asp:Label ID="lblStoreName" runat="server"></asp:Label>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="style1" colspan="2">
                                                <asp:Button ID="btnSelectReq" runat="server" onclick="btnSelectReq_Click" 
                                                    Text="Select New Requisition" />
                                            </td>
                                        </tr>
                                    </table>
                                    <br />
                                    <asp:GridView ID="gvRequisitionItems" runat="server" 
                                        AutoGenerateColumns="False" onrowcommand="gvRequisitionItems_RowCommand">
                                        <RowStyle HorizontalAlign="Right" VerticalAlign="Middle" />
                                        <Columns>
                                            <%--<asp:BoundField DataField="ItemID" HeaderText="No." />
                                            <asp:BoundField DataField="ItemName" HeaderText="Name" />--%>
                                            <asp:TemplateField HeaderText="Item Name">
                                                <ItemTemplate>
                                                    <asp:Label runat="server" ID="lblItemID" Visible="false" Text='<%# Eval("ItemID") %>'></asp:Label>
                                                    <asp:Label runat="server" ID="lblItemName" Text='<%# Eval("ItemName") %>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:BoundField DataField="RequisitionQty" HeaderText="Qty Ordered" />
                                            <asp:TemplateField HeaderText="Cost per Item<br/ > GH¢">
                                                <ItemTemplate>
                                                    <asp:Label runat="server" ID="lblVendorCost" Text='<%# String.Format("{0:0.00}", Eval("avgCost")) %>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="Total Cost<br/ > GH¢">
                                                <ItemTemplate>
                                                    <asp:Label runat="server" ID="lblTotalVendorCost" Text='<%# CalcCost(Eval("RequisitionQty"), Eval("avgCost")) %>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:BoundField DataField="TotalQuantity" HeaderText="Qty in Stock" />
                                            <asp:BoundField DataField="ReceivedQty" HeaderText="Qty Received" 
                                                Visible="False" />
                                            <asp:ButtonField ButtonType="Button" CommandName="Deny" Text="Deny" />
                                            <asp:TemplateField HeaderText="Status">
                                                <ItemTemplate>
                                                    <asp:Label runat="server" ID="lblStatusName" Text='<%# Bind("StatusName") %>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                        </Columns>
                                    </asp:GridView>
                                    <br />
                                    <table>
                                        <tr>
                                            <td>
                                                <label>Comments:</label>
                                            </td>
                                            <td rowspan="2">
                                                <asp:TextBox runat="server" width="300px" TextMode="multiline" ID="txtComments"></asp:TextBox>
                                            </td>
                                            <td>
                                                <asp:Button ID="btnSaveComments" runat="server" onclick="btnSaveComments_Click" Text="Save Comments" />
                                            </td>
                                        </tr>
                                    </table>
                                    <asp:Button ID="btnSubmit" runat="server" onclick="btnSubmit_Click" 
                                        Text="Approve All" />
                                    <br />
                                    <br />
                                    <fieldset>
                                <legend>Signature</legend>
                                <table style="width:100%;">
                                    <tr>
                                        <td class="style4">
                                            <asp:Label ID="lblGMSig0" runat="server" Font-Bold="true" Text="GM Signature:"></asp:Label>
                                        </td>
                                        <td>
                                            <asp:Label ID="lblGMSigned0" runat="server"></asp:Label>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="style4">
                                            <asp:Label ID="lblCEOSig0" runat="server" Font-Bold="true" Text="CEO Signature:"></asp:Label>
                                        </td>
                                        <td>
                                            <asp:Label ID="lblCEOSigned0" runat="server"></asp:Label>
                                        </td>
                                    </tr>
                                </table>
                            </fieldset><br />
                                </asp:View>
                            </asp:MultiView>
                            <br />
                            
                    </ContentTemplate>
                </asp:TabPanel>
                <asp:TabPanel ID="ARRequisitions" runat="server" HeaderText="View Requisitions">
                    <ContentTemplate>
                        <fieldset style="width: 573px;">
                            <legend>Active Requisitions</legend>
                            <asp:MultiView ID="MultiView1" runat="server">
                                <asp:View ID="View1" runat="server">
                                    <asp:GridView ID="gvARRequisitions0" runat="server" AutoGenerateColumns="False">
                                        <Columns>
                                            <asp:BoundField DataField="RequisitionID" HeaderText="Requisition ID" />
                                            <asp:BoundField DataField="RequisitionName" HeaderText="Name" />
                                            <asp:BoundField DataField="OrderDate" HeaderText="Order Date" />
                                            <asp:BoundField DataField="StatusID" HeaderText="Status" />
                                            <asp:ButtonField ButtonType="Button" Text="Select" />
                                        </Columns>
                                    </asp:GridView>
                                </asp:View>
                                <asp:View ID="View2" runat="server">
                                    <asp:GridView ID="gvARRequisitionsItems" runat="server" 
                                        AutoGenerateColumns="False">
                                        <Columns>
                                            <%--<asp:BoundField DataField="ItemID" HeaderText="No." />
                                            <asp:BoundField DataField="ItemName" HeaderText="Name" />--%>
                                            <asp:TemplateField HeaderText="Item Name">
                                                <ItemTemplate>
                                                    <asp:Label runat="server" ID="lblItemID" Visible="false" Text='<%# Eval("ItemID") %>'></asp:Label>
                                                    <asp:Label runat="server" ID="lblItemName" Text='<%# Eval("ItemName") %>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:BoundField DataField="RequisitionQty" HeaderText="Qty. Ordered" />
                                            <asp:BoundField DataField="QtyReceived" HeaderText="Qty. Received" />
                                            <asp:BoundField DataField="Last Received Date" 
                                                HeaderText="Last Received Date" />
                                        </Columns>
                                    </asp:GridView>
                                    <br />
                                    <fieldset>
                                        <legend>Signature</legend>
                                        <table style="width:100%;">
                                            <tr>
                                                <td class="style4">
                                                    <asp:Label ID="lblGMSig" runat="server" Font-Bold="true" Text="GM Signature:"></asp:Label>
                                                </td>
                                                <td>
                                                    <asp:Label ID="lblGMSigned" runat="server"></asp:Label>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="style4">
                                                    <asp:Label ID="lblCEOSig" runat="server" Font-Bold="true" Text="CEO Signature:"></asp:Label>
                                                </td>
                                                <td>
                                                    <asp:Label ID="lblCEOSigned" runat="server"></asp:Label>
                                                </td>
                                            </tr>
                                        </table>
                                    </fieldset><br />
                                </asp:View>
                            </asp:MultiView>
                        </fieldset>
                    </ContentTemplate>
                    </asp:TabPanel>
                 <asp:TabPanel ID="TabPanel1" runat="server" HeaderText="View Requisitions">
                 <ContentTemplate>
                        <fieldset style="width: 573px;">
                            <legend>Active Requisitions</legend>
                            <asp:MultiView ID="mvProc" runat="server" ActiveViewIndex="0">
                                <asp:View ID="View3" runat="server">
                                    <asp:Label ID="lblProcMessage" runat="server" ForeColor="Red"></asp:Label>
                                    <asp:GridView ID="gvProcRequisition" runat="server" AutoGenerateColumns="False" 
                                        onrowcommand="gvProcRequisition_RowCommand">
                                        <Columns>
                                            <asp:BoundField DataField="RequisitionID" HeaderText="RequisitionID" />
                                            <asp:BoundField DataField="RequisitionName" HeaderText="Name" />
                                            <asp:BoundField DataField="orderDate" HeaderText="OrderDate" />
                                            <asp:ButtonField ButtonType="Button" CommandName="Choose" Text="Select" />
                                        </Columns>
                                    </asp:GridView>
                                </asp:View>
                                <asp:View ID="View4" runat="server">
                                    <table style="width:100%;">
                                        <tr>
                                            <td class="style5">
                                                <asp:Label ID="lblProcRequisitionID" runat="server"></asp:Label>
                                            </td>
                                            <td>
                                                <asp:Label ID="lblProcDate" runat="server"></asp:Label>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td colspan="2">
                                                <asp:Label ID="lblProcDescription" runat="server"></asp:Label>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="style5">
                                                <asp:Button ID="btnSelectNewProc" runat="server" 
                                                    OnClick="btnSelectNewProc_Click" Text="Select New Requisition" />
                                            </td>
                                            <td>
                                                &nbsp;</td>
                                        </tr>
                                    </table>
                                    <br />
                                    <asp:GridView ID="gvProcItem" runat="server" AutoGenerateColumns="False" 
                                        OnRowCommand="gvProcItem_RowCommand" onrowdatabound="gvProcItem_RowDataBound">
                                        <Columns>
                                            <%--<asp:BoundField DataField="ItemID" HeaderText="No." />
                                            <asp:BoundField DataField="ItemName" HeaderText="Name" />--%>
                                            <asp:TemplateField HeaderText="Item Name">
                                                <ItemTemplate>
                                                    <asp:Label runat="server" ID="lblItemID" Visible="false" Text='<%# Eval("ItemID") %>'></asp:Label>
                                                    <asp:Label runat="server" ID="lblItemName" Text='<%# Eval("ItemName") %>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:BoundField DataField="RequisitionQty" HeaderText="Ordered" />
                                            <asp:BoundField DataField="StatusName" HeaderText="Status" />
                                            <asp:ButtonField ButtonType="Button" CommandName="Order" Text="Ordered" />
                                            <asp:ButtonField ButtonType="Button" CommandName="Remove" Text="Cannot Order" />
                                        </Columns>
                                    </asp:GridView>
                                    <br />
                                </asp:View>
                                </asp:MultiView>
                                </fieldset>
                                </ContentTemplate>
                </asp:TabPanel>
            </asp:TabContainer>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
